package com.intellagric.controller.module.ift_equipment;

import com.intellagric.common.pojo.LayuiDataGridResult;
import com.intellagric.common.pojo.ResponseMessage;
import com.intellagric.module.iftmonitor.EquipmentStatusVo;
import com.intellagric.pojo.IftEquipmentStatus;
import com.intellagric.service.iftmonitor.ift_equipment.EquipmentStatusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.UUID;

/**
 * @Author: zhy
 * @email: 1269679946@qq.com
 * @Date: 2018/10/23
 * @DESC： 设备状态管理
 */
@Controller
public class EquipmentStatusController {

    @Autowired
    private EquipmentStatusService equipmentStatusService;

    /**
     * 添加目标信息
     * @Param equipmentStatus
     * @return ResponseMessage
     */
    @RequestMapping("/equipment/status/add")
    @ResponseBody
    public ResponseMessage add(IftEquipmentStatus equipmentStatus) {
        equipmentStatus.setId(UUID.randomUUID().toString().replaceAll("-",""));
        equipmentStatus.setCreateDate(new Date());
        equipmentStatus.setUpdateDate(new Date());
        return equipmentStatusService.addEquipmentStatus(equipmentStatus);
    }

    /**
     * 删除目标信息
     * @Param id
     * @return ResponseMessage
     */
    @RequestMapping("/equipment/status/delete")
    @ResponseBody
    public ResponseMessage delete(String id) {
        return equipmentStatusService.deleteEquipmentStatus(id);
    }

    /**
     * 修改目标信息
     * @Param
     * @return ResponseMessage
     */
    @RequestMapping("/equipment/status/edit")
    @ResponseBody
    public ResponseMessage edit(IftEquipmentStatus equipmentStatus) {
        equipmentStatus.setUpdateDate(new Date());
        equipmentStatus.setCreateDate(new Date());
        return equipmentStatusService.editEquipmentStatus(equipmentStatus);
    }

    /**
     * 查询目标信息
     * @return IftEquipment
     */
    @RequestMapping("/equipment/status/{id}")
    @ResponseBody
    public IftEquipmentStatus get(@PathVariable String id) {
        return equipmentStatusService.getEquipmentStatusById(id);
    }

    /**
     * 查询目标信息
     * @return IftEquipment
     */
    @RequestMapping("/equipment/status/query")
    @ResponseBody
    public LayuiDataGridResult getByVo(EquipmentStatusVo equipmentStatusVo) {
        return equipmentStatusService.getEquipmentStatusListByVo(equipmentStatusVo);
    }

    /**
     * 查询目标信息列表
     * @return LayuiDataGridResult
     */
    @RequestMapping("/equipment/status/list")
    @ResponseBody
    public LayuiDataGridResult getList() {
        return equipmentStatusService.getEquipmentStatusList();
    }

    /**
     * 分页查询目标信息列表
     * @return LayuiDataGridResult
     */
    @RequestMapping("/equipment/status/page")
    @ResponseBody
    public LayuiDataGridResult getPage(int page,int limit) {
        return equipmentStatusService.getEquipmentStatusPage(page,limit);
    }

}
